# 0. 导入必要的库
from util import load,get,dump
from lazypredict.Supervised import LazyClassifier


# 1. 加载训练集和测试集
Xy_root = get('Xy_root')
X_train, X_test, y_train, y_test = load("X_train, X_test, y_train, y_test", f'{get("Xy_root")}/Xy')
X2_train, X2_test, y2_train, y2_test = load("X2_train, X2_test, y2_train, y2_test", f'{get("Xy_root")}/Xy2')
X3_train, X3_test, y3_train, y3_test = load("X3_train, X3_test, y3_train, y3_test", f'{get("Xy_root")}/Xy3')

# 2. 使用LazyClassifier进行快速模型评估
print("开始评估所有的模型:")
clf = LazyClassifier()

scores, _ = clf.fit(X_train, X_test, y_train, y_test)
print("传统方法:", scores) # 打印不同模型的评估结果对比

scores2, _ = clf.fit(X2_train, X2_test, y2_train, y2_test)
print("HOG方法:", scores2)

scores3, _ = clf.fit(X3_train, X3_test, y3_train, y3_test)
print("VGG16方法:", scores3)


# # 3. 获取F1分数最高的模型
# # 获取F1分数最高的模型名称
# best_model_name = scores['F1 Score'].idxmax()  # 获取F1分数最高行的索引值，即：模型名称
# print("F1分数最高的模型是: ", best_model_name)
# # 根据模型名称，从模型字典中获取模型对象
# best_model = clf.models[best_model_name]
#
# # 4. 序列化最佳模型
# dump(best_model, "最好的F1分数的模型", f'{get("model_root")}/best_model')
